Crate rusticata_macros[][src]

Expand description

Rusticata-macros

Helper macros for the rusticata project.

This crate contains some additions to nom.

For example, the error_if! macro allows to test a condition and return an error from the parser if the condition fails:

use rusticata_macros::error_if;
let r : IResult<&[u8],()> = do_parse!(
    s,
    l: be_u8 >>
    error_if!(l < 4, ErrorKind::Verify) >>
    data: take!(l - 4) >>
    (())
    );

See the documentation for more details and examples.

Re-exports

pub use macros::*;

Modules

General purpose combinators

Helper functions and structures for debugging purpose

Helper macros

Macros

Align input value to the next multiple of 4 bytes

Align input value to the next multiple of n bytes Valid only if n is a power of 2

Helper macro for nom parsers: run first parser if condition is true, else second parser

Helper macro for nom parsers: raise error if the condition is true

emptyDeprecated

Helper macro for nom parsers: raise error if input is not empty

Helper macro for nom parsers: raise error if the condition is true

Combination and flat_map! and take! as first combinator

Helper macro for newtypes: declare associated constants and implement Display trait

Read a slice as a big-endian value.

Nom combinator that returns the given expression unchanged

Parse a slice and return a fixed-sized array of bytes

Apply combinator, trying to “upgrade” error to next error type (using the Into or From traits).

Apply combinator, trying to “upgrade” error to next error type (using the Into or From traits).

Traits

Common trait for structures serialization